<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_default
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<script type="text/javascript">
function editTag(id, name) {
	var new_name = prompt('Please type new tag name', name)
	if (new_name) {
		var req = new Ajax.Request('/tag/index/update', { 
			method:'post',
			parameters: {
				tagname: new_name, 
				tag_id: id
			},
			onSuccess: function(req, json){
				eval('var json = ' + req.responseText);
				if (1 === json.error) {				
					alert(json.error_message);
				}
			}
		});	
	}
}

function deleteTag(id) {
	if (confirm('Do tou realy want to delete the Tag?')) {
		var req = new Ajax.Request('/tag/index/delete', { 
			method:'post',
			parameters: {
				tag_id: id
			},
			onSuccess: function(req, json){
				eval('var json = ' + req.responseText);
				if (1 === json.error) {				
					alert(json.error_message);
				}
			}
		});	
	}
}
</script>

<?php foreach ($collection->getItems() as $tag) { /* $tag = $tag->getData();*/ ?> 
	<span>
		<a style="font-size:<?php echo $collection->getFSize($tag->getTag_id()); ?>" href="/tag/index/show?tag=<?php echo $tag->getTagname(); ?>">
			<?php echo $tag->getTagname(); ?>
		</a> 
		<span>
			<a href="#" title="edit tag" onclick="editTag(<?php echo $tag->getTag_id(); ?>, '<?php echo $tag->getTagname(); ?>'); return false;">e</a> 
			<a href="#" title="delete tag" onclick="deleteTag(<?php echo $tag->getTag_id(); ?>); return false;">d</a>
		</span>
	</span>
<?php } ?>
